/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.jboss.seam.example.booking.action;

import javax.persistence.EntityManager;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Begin;
import org.jboss.seam.annotations.End;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.example.booking.entity.Hotel;
import org.jboss.seam.framework.Controller;

/**
 *
 * @author RHO
 */
@AutoCreate
@Name("hotelViewPage")
@Scope(ScopeType.CONVERSATION)
@Restrict("#{identity.loggedIn}")
public class HotelViewPage extends Controller {

    @In
    protected EntityManager entityManager;
    
    @Out(required = false)
    @In(required = false)
    private Hotel hotel;

    @Begin(join = true)
    public String show(String hotelId) {
        setHotel(entityManager.find(Hotel.class, Long.parseLong(hotelId)));
        return "show_hotel_view";
    }

    @End
    public String showHotelList() {
        return "show_hotel_list";
    }

    public Hotel getHotel() {
        return hotel;
    }

    public void setHotel(Hotel hotel) {
        this.hotel = hotel;
    }
    
    
    
}
